package com.zn.service.impl;

import com.zn.entity.AppVersion;
import com.zn.mapper.AppVersionMapper;
import com.zn.service.AppVersionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author YinJiaWei
 * @version 2018/10/15 13:38
 */
@Service
public class AppVersionServiceImpl implements AppVersionService {
    @Autowired
    private AppVersionMapper appVersionMapper;
    @Override
    public AppVersion appVersionUpdate(AppVersion parameterAppVersion) {
        AppVersion appVersion=appVersionMapper.existNewVersion(parameterAppVersion);
        /**如果是普通更新 查询是否存在强制更新的版本号**/
        if(appVersion != null && appVersion.getChangeProperties()!=null
                && appVersion.getChangeProperties()==1){
            int exist=appVersionMapper.existForceUpdateVersion(parameterAppVersion);
            appVersion.setChangeProperties(exist>0?2:appVersion.getChangeProperties());
        }
        return appVersion;
    }
}
